import request from '@/utils/request'
import form from '@/utils/form'
const api = 'partyConference/'

/**
 * 获取指定
 *
 * @export
 * @param {*} { id, page }
 * @return {*}
 */
export function getConferRecord({ id, page }) {
  return request.get(`${api}conferRecord`, {
    params: Object.assign({
      id
    }, page)
  })
}

/**
 * 更新
 *
 * @export
 * @param {*} {
 * data:{
 *    int:type,
 *    Array.string:userId,
 *    guid:conferenceId,
 *    datetime:create
 * }
 * , allowOverWrite, auth }
 * @return {*}
 */
export function postConferRecord({ allowOverWrite, isRemoved, id, type, userId, conferenceId }) {
  return request.post(`${api}conferRecord`, {
    data: {
      id, isRemoved, type,
      userId: [userId],
      conferenceId
    },
    allowOverWrite
  })
}

/**
 * 获取会议内容
 *
 * @export
 * @param {*} {
 *  records 记录id 数组,
 *  conferid 会议id 单个,
 *  page 分页,
 *  auth 授权
 *  }
 * @return {*}
 */
export function getConferRecordContent({ records, conference, pages, auth }) {
  return request.post(`${api}conferRecordContents`, {
    data: {
      records: form.toQueryArrays(records),
      conference: form.toQueryValue(conference),
      page: pages
    },
    auth
  })
}

/**
 * 更新会议内容
 *
 * @export
 * @param {*} {
 * data:{
 *    boolen:isRemoved,
 *    int:contentType,
 *    string:content,
 *    datetime:create,
 *    guid:id,
 *    list guid:records
 * }
 * , allowOverWrite, auth }
 * @return {*}
 */
export function postConferRecordContent({ id, isRemoved, records, contentType, content }) {
  const allowOverWrite = true
  return request.post(`${api}conferRecordContent`, {
    data: {
      id, isRemoved, records, contentType, content
    },
    allowOverWrite
  })
}

export default {
  postConferRecord,
  postConferRecordContent,
  getConferRecord,
  getConferRecordContent
}
